<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="pg" uri="/tags/pagination"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<s:include value="../include.jsp"></s:include>
		<title>无忧在学前首页管理</title>
		<script type="text/javascript">
	var count = 0;
	function save() {
		var isShow1 = document.getElementsByName("isShow1");
		var isShow2 = document.getElementsByName("isShow2");
		var isShow3 = document.getElementsByName("isShow3");
		var chkedMenuId = "";
		if (isShow1) {
			for (i = 0; i < isShow1.length; i++) {
				if (isShow1[i].checked) {
					chkedMenuId += isShow1[i].value
							+ "|"
							+ document.getElementById(isShow1[i].id.replace(
									"isShow", "showSort")).value + ",";
				}
			}
		}
		if (isShow2) {
			for (i = 0; i < isShow2.length; i++) {
				if (isShow2[i].checked) {
					chkedMenuId += isShow2[i].value
							+ "|"
							+ document.getElementById(isShow2[i].id.replace(
									"isShow", "showSort")).value + ",";
				}
			}
		}
		if (isShow3) {
			for (i = 0; i < isShow3.length; i++) {
				if (isShow3[i].checked) {
					chkedMenuId += isShow3[i].value
							+ "|"
							+ document.getElementById(isShow3[i].id.replace(
									"isShow", "showSort")).value + ",";
				}
			}
		}
		alert('1');
		if (chkedMenuId == "") {
			alert("请选择至少21个类别");
			return;
		} else {
			chkedMenuId = chkedMenuId.substring(0, chkedMenuId.length - 1);
		}
		var count = chkedMenuId.split(",").length;
		if (count<21 || count>24) {
			alert("类别选取个数不能少于21个，不能大于24个");
			return;
		}
		document.getElementById("chkedMenuId").value = chkedMenuId;
		chgAction("preSchoolManageAction", "save");
		document.forms[0].submit();
	}

	function checkOpt(chk, param) {
		if (chk.checked) {
			if (count == 24) {
				alert("您已经勾选了24个类别，不允许再新增类别了");
				chk.checked = false;
				return;
			}
			document.getElementById(param).disabled = false;
			document.getElementById(param).value = "1";
			count++;
		} else {
			document.getElementById(param).disabled = true;
			document.getElementById(param).value = "";
			count--;
		}
		document.getElementById("num").innerHTML = count;
	}

	function getChkedCount() {
		var isShow1 = document.getElementsByName("isShow1");
		var isShow2 = document.getElementsByName("isShow2");
		var isShow3 = document.getElementsByName("isShow3");
		if (isShow1) {
			for (i = 0; i < isShow1.length; i++) {
				if (isShow1[i].checked) {
					count++;
				}
			}
		}
		if (isShow2) {
			for (i = 0; i < isShow2.length; i++) {
				if (isShow2[i].checked) {
					count++;
				}
			}
		}
		if (isShow3) {
			for (i = 0; i < isShow3.length; i++) {
				if (isShow3[i].checked) {
					count++;
				}
			}
		}
		document.getElementById("num").innerHTML = count;
	}

	<s:if test="operateResult=='suc'">
	alert("保存成功");
	</s:if>
	<s:elseif test="operateResult=='fail'">
	alert("保存失败");
	</s:elseif>
</script>
	</head>
	<body onload="getChkedCount()">
		<div class="outerDiv" style="height: 480px; overflow-y: auto;">
			<s:form name="form1" action="preSchoolManageAction" method="post">
				<s:hidden name="chkedMenuId" id="chkedMenuId"></s:hidden>
			</s:form>
			<div class="top_box">
				您的位置：基础功能&gt;&gt;
				<span class="red">无忧在学前首页管理</span>
			</div>
			请从“婴幼儿教育”，“文艺/体育”，“外语”三个一级课程类别中，选择
			<font color="red">21～24</font>个对应的三级类别，在无忧在学前首页的课程栏目tab中显示。
			<br>
			目前，三级类别已被勾选了
			<font color="red" size="3" id="num">0</font>个
			<div class="form_list_box">
				<ul>
					<li>
						<font size="3"><b>婴幼儿教育</b> </font>
						<ul>
							<s:iterator value="childList" id="list1" status="mst">
									<s:if test="#mst.index%7==0">
										<br>
									</s:if>
									<input type="checkbox" name="isShow1"
										<s:if test="isShow==1">checked</s:if>
										id="<s:property value="#mst.index"/>_isShow1"
										value='<s:property value="menuId"/>'
										onclick="checkOpt(this,'<s:property value="#mst.index"/>_showSort1')" />
									<s:property value="menuName" />
									<input type="text" maxlength="2" title="显示顺序1～24"
										style="width: 13px"
										<s:if test="isShow==1">value='<s:property value="showSort"/>'</s:if>
										<s:else>disabled="true"</s:else>
										name="<s:property value="#mst.index"/>_showSort1"
										id='<s:property value="#mst.index"/>_showSort1' />
									&nbsp;&nbsp;&nbsp;&nbsp;
							</s:iterator>
						</ul>
					</li>
					<li>
						<font size="3"><b>文艺/体育</b> </font>
						<ul>
							<s:iterator value="artList" id="list2" status="mst">
								<s:if test="#mst.index%7==0">
									<br>
								</s:if>
								<input type="checkbox" name="isShow2"
									<s:if test="isShow==1">checked</s:if>
									id="<s:property value="#mst.index"/>_isShow2"
									value='<s:property value="menuId"/>'
									onclick="checkOpt(this,'<s:property value="#mst.index"/>_showSort2')" />
								<s:property value="menuName" />
								<input type="text" maxlength="2" title="显示顺序1～24"
									style="width: 13px"
									<s:if test="isShow==1">value='<s:property value="showSort"/>'</s:if>
									<s:else>disabled="true"</s:else>
									name="<s:property value="#mst.index"/>_showSort2"
									id='<s:property value="#mst.index"/>_showSort2' />
														&nbsp;&nbsp;&nbsp;&nbsp;
						</s:iterator>
						</ul>
					</li>
					<li>
						<font size="3"><b>外语</b> </font>
						<ul>
							<s:iterator value="languageList" id="list3" status="mst">
								<s:if test="#mst.index%7==0">
									<br>
								</s:if>
								<input type="checkbox" name="isShow3"
									<s:if test="isShow==1">checked</s:if>
									id="<s:property value="#mst.index"/>_isShow3"
									value='<s:property value="menuId"/>'
									onclick="checkOpt(this,'<s:property value="#mst.index"/>_showSort3')" />
								<s:property value="menuName" />
								<input type="text" maxlength="2" title="显示顺序1～24"
									style="width: 13px"
									<s:if test="isShow==1">value='<s:property value="showSort"/>'</s:if>
									<s:else>disabled="true"</s:else>
									name="<s:property value="#mst.index"/>_showSort3"
									id='<s:property value="#mst.index"/>_showSort3' />
														&nbsp;&nbsp;&nbsp;&nbsp;
							</s:iterator>
						</ul>
					</li>
				</ul>
				<div class="btn_box">
					<a href="#" onclick="save()"><s></s>保存</a>
				</div>
			</div>
		</div>
	</body>
</html>